//
//  UIButton+TestTheme.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2021/3/22.
//  Copyright © 2021 moon. All rights reserved.
//

#import "UIButton+TestTheme.h"

@interface TestUIButtonPicker : MKUIThemePickerBase
@property(nonatomic,strong) id<MKUIThemeElementProtocol> normalImageElement;
@property(nonatomic,strong) id<MKUIThemeElementProtocol> highlightImageElement;
@end
@implementation TestUIButtonPicker
- (void)applyThemeTo:(NSObject *)object{
    UIImage *normalImage = [self.class themeUIImageWithElement:self.normalImageElement];
    UIImage *highlightImage = [self.class themeUIImageWithElement:self.highlightImageElement];
    void (*mp)(id, SEL,UIImage *,UIImage *) = (void (*)(id, SEL,UIImage *,UIImage *))[object methodForSelector:self.objSelector];
    mp(object,self.objSelector,normalImage,highlightImage);
}
@end

@implementation UIButton (TestTheme)
- (void)test_setNormalImage:(UIImage *)normalImage highlightImage:(UIImage *)highlightImage{
    [self setImage:normalImage forState:UIControlStateNormal];
    [self setImage:highlightImage forState:UIControlStateHighlighted];
}
- (void)mktheme_test_setNormalImage:(id<MKUIThemeElementProtocol>)normalImage highlightImage:(id<MKUIThemeElementProtocol>)highlightImage{
    TestUIButtonPicker *picker = [[TestUIButtonPicker alloc] initWithObjSelector:@selector(test_setNormalImage:highlightImage:)];
    picker.normalImageElement = normalImage;
    picker.highlightImageElement = highlightImage;
    [self mktheme_setPicker:picker];
}
@end

